home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / spiele / sgac / manual / chapter3.doc < prev    next >
Text File  |  1989-07-28  |  15KB  |  367 lines

  1.                          Chapter three
  2.  
  3.                        (The Editor Program)
  4.  
  5.  Once our data is tested we can spruce it up a bit by adding extra 
  6.  routines, this is where this program comes in. The editor 
  7.  Program is a bundle of routines which handles your saved game 
  8.  data from the Creator which allows you to take, drop and examine 
  9.  objects, read your location descriptions and so on.
  10.  
  11.  If you have been playing about with the Test.prg program then you 
  12.  will see what I mean, but at the moment we can't access any of 
  13.  the other zones except for the Connection and Examine zones.
  14.  
  15.  So what we have to do is use Stos itself to add the extras, so 
  16.  load it up, and insert this disk. The file we want is called 
  17.  'editor.bas', so load it up by using the file selector (F4) and 
  18.  clicking on "editor.bas" or just type..load"editor".
  19.  
  20.  Type "list" and press Return. The program is as you see a bundle 
  21.  of routines to handle your game data, there are also long lists 
  22.  of 'REM' statements, the first 'REM' what the following list of 
  23.  statements are used for, our routines go in between these lines.
  24.  
  25.    Lines 160 to 240   (Varibles) 
  26.  
  27.  These lines are used for your own Varibles, these are set to 
  28.  indicate the state of something, for example, if we had a dragon 
  29.  in our game we could define a varible called 'DRAGON', this could 
  30.  be set to either 0 or 1 depending on the state of the dragon.
  31.  
  32.  DRAGON=0 : (Dragon is dead)
  33.  DRAGON=1 : (Dragon is alive)
  34.  
  35.  So we could set the varible to one at the start of the game to 
  36.  indicate the dragon is alive and set it to nought if killed.
  37.  
  38.  Varibles don't just have to be used for life and death, there can 
  39.  be used to check if a character has been hit, examined or spoken 
  40.  to, In Grannies Garden, a varible has been used to check if the 
  41.  keeper of the lake has been given the key and if not, he will ask 
  42.  for it. Also the elf in the forest will come up to you every time 
  43.  you enter that location until you put the fire out.
  44.  
  45.  ELF=0 : (Fire has been put out and elf gone)
  46.  ELF=1 : (Fire is still going and elf still there)
  47.  
  48.  Varibles can have as many values as you want. You could set the 
  49.  players energy to ten and take one away from the varible until it 
  50.  reaches nought. You can create interesting effects with this.
  51.  
  52.  ENERGY=10 : (Players energy is up to full)
  53.  ENERGY=5 : (Player is feeling weak)
  54.  ENERGY=0 : (Player is dead)
  55.  
  56.  See if you can think of anymore ways the varibles can be used. 
  57.  But remember that there are two used by the editor program that 
  58.  could cause programs if used. They are LO and OB and they hold 
  59.  the number of locations and objects.
  60.  
  61.    Lines 260 to 430   (Game intro) 
  62.  
  63.  This lines are used for an intro to your game, this could be just 
  64.  a title screen and some music playing. Once the player press a 
  65.  key or mouse button the game can start.
  66.  
  67.  430 if mouse key then goto 500 (start of game)
  68.  
  69.    Line 500  (Subroutine to line 9000 for extra routines) 
  70.  
  71.  Before the game allows input to the player this line is used to 
  72.  check for any routines at the end of the editor. This is mainly 
  73.  used to put drawings of characters on the screen like the guard 
  74.  in Grannies Garden, the routines are entered from line 9000 
  75.  onwards which are checked at the start of every location.
  76.  
  77.  ie: 500 gosub 9000
  78.  
  79.  See EXTRA.DOC for more info on this. 
  80.  
  81.  Don'nt forget to put a RETURN command at the end of each line in 
  82.  this section. More on this later.
  83.  
  84.    Lines 750 to 1030   (High Priority Events) 
  85.  
  86.  These events are used to check the location before giving control 
  87.  to the player, these are messages that appear just after the 
  88.  location description and imform the player that something has 
  89.  happened in the room that they were'nt told about in the location 
  90.  description, Such an event could be a character appearing on the 
  91.  scene or that the state of something is the location has changed.
  92.  
  93.  These messages are entered, using the creator, in the Game 
  94.  Messages menu, so the messages we need are game messages.
  95.  
  96.  Lets say that we had a troll at location five and we wanted to 
  97.  imform the player of his state, we could first define a varible 
  98.  called TROLL which would be set to one if he was alive and nought 
  99.  if he was dead. We would enter two game messages in the creator.
  100.  
  101.    Game message 1 
  102.  
  103.  There is a dead troll here.
  104.  
  105.    Game Message 2 
  106.  
  107.  There is a nasty looking troll here.
  108.  
  109.  We then use our H_P event.
  110.  
  111.  750 if LOCATION=5 and TROLL=0 then print MESSAGE$(1)
  112.  
  113.  The varible 'LOCATION' holds the number of the location that the 
  114.  player is in so in this line first checks if he is in location 
  115.  number five, if he is'nt then this line is ignored.
  116.  
  117.  The MESSAGE$(1) is an array created using the DIM command and it 
  118.  loads all the game messages that we entered. so if this line is 
  119.  used then game message number one is printed which tells us that 
  120.  the troll is dead. We now need one to see if he's alive.
  121.  
  122.  760 if LOCATION=5 and TROLL=1 then print MESSAGE$(2)
  123.  
  124.  So if the player is in location five and the troll is alive then 
  125.  print game message two to imform the player.
  126.  
  127.  Other example could be if we wanted to check if the player 
  128.  entered a dragons cave, if he was carrying a shield then he would 
  129.  be safe from the dragon's fire otherwise he would be burnt to a 
  130.  frazzle. To do this we would use an H_P to check the state of the 
  131.  dragon, if the player is in the same location and if he's 
  132.  carrying the shield. Using the Object Menu, we would create a 
  133.  shield object and put it in a normal location.
  134.  
  135.  We could check this with the following H_P event.
  136.  
  137.  770 if LOCATION=10 and DRAGON=1 and OBLOC(2)=CARRIED then print 
  138.      MESSAGE$(3)
  139.  
  140.  The OBLOC array holds the location of all the objects in the game 
  141.  so this line says, if the player is in location ten (the cave) 
  142.  and the dragon is alive and the location of object number two 
  143.  (the shield) is carried by the player then print game message one 
  144.  to tell the player that the dragon's fire has no effect as he has 
  145.  the shield. Here are some more examples of OBLOC.
  146.  
  147.   OBLOC(1)=5 : (Object 1 is in location 5)
  148.   OBLOC(2)=CARRIED : (Object 2 is carried by the player)
  149.   OBLOC(3)=WN : (Object 3 is worn by the player)
  150.   OBLOC(4)=NC : (Object 4 is not created)
  151.  
  152.  So, as the player has the shield he is safe, but what if he 
  153.  does'nt have it, we can check with this line.
  154.  
  155.  780 if LOCATION=5 and DRAGON=1 and OBLOC(2)<>CARRIED then print 
  156.      MESSAGE$(4) : goto DEATH
  157.  
  158.  So, if the shield's location is in any other place but carried 
  159.  then game message 4 is printed so tell the player he has just 
  160.  been burned to death by the dragon. As we want the game to end 
  161.  because the player has been killed then we add the "goto DEATH" 
  162.  statement at the end of the line, the varible DEATH holds the 
  163.  line number of the finish game routine.
  164.  
  165.  Can you think of anymore H_P events you can use?
  166.  
  167.    Lines 1380 to 1670   (Special Take Events) 
  168.  
  169.  At the moment, the editor program will put any objects the 
  170.  player has just taken and put them in the carried postion, but 
  171.  sometimes, taking an object could result in something else 
  172.  happening like another object being found or getting caught by a 
  173.  character who nicks you for stealing the object.
  174.  
  175.  This line would check that if a vase was taken, a key would fall 
  176.  out of it.
  177.  
  178.  1380 if TAKE$="Vase" and OBLOC(5)=NC then OBLOC(5)=LOCATION : 
  179.       print MESSAGE$(5) : SC=SC+20 : DONE=1
  180.  
  181.  When the player clicks on an object to take it, the objects ID 
  182.  word goes into the varible 'TAKE$' so this varible contains the 
  183.  word just chosen by the player. 
  184.  
  185.  As we only want the key to be found when the player takes the 
  186.  vase for the first time we use the OBLOC(5) statement to check 
  187.  that object 5 (the key) is not created so if he drops the vase 
  188.  then takes it again, this line won't be used because the key has 
  189.  been created and in another location.
  190.    
  191.  Now we know that the vase object has been taken and the key has 
  192.  not been created (ie: not found yet), we can put the key's 
  193.  location at the players present location. The SC varible holds 
  194.  the players score and this line adds 20 points to it if the key 
  195.  is found, finally we add a'DONE=1' at the end because the line 
  196.  has been used by the game.
  197.  
  198.    Lines 1910 to 2200   (Special Drop Events) 
  199.  
  200.  These events are used in the same way as the Take Events only 
  201.  that we can cause things to happen like dropping a vase would 
  202.  result in it breaking into pieces. 
  203.  
  204.  When the player selects an object to drop, the objects name goes 
  205.  into a varible called 'DROP$', this could be used like this.
  206.  
  207.  1910 if DROP$="Vase" then OBLOC(6)=NC : OBLOC(7)=LOCATION : print 
  208.       MESSAGE$(1) : goto 2300
  209.  
  210.  We don't need to check the location of the vase (object 6) 
  211.  because the editor program will only come to this routine if the 
  212.  object is carried and the end of this line goes to line 2300 
  213.  which is the player input routine, it stops the object goes to 
  214.  the players location as normal.
  215.  
  216.  We have an interesting feature at this line, we kill one object 
  217.  and put another there, Object 6 is a vase and object 7 is a 
  218.  broken vase, the broken vase is in the not created location.
  219.  
  220.  So what happens is, because the vase was dropped, we swap it for 
  221.  the broken vase, so the vase goes out of the game by being put in 
  222.  the not created location (NC) and the broken vase goes to the 
  223.  players location. So the game message in the above line tells the 
  224.  player that as he drops the vase it breaks and he sees the broken 
  225.  vase at his location instead of the un-broken one.
  226.  
  227.  An important thing to remember is that when using the 'TAKE$' and 
  228.  the 'DROP$' varibles is that the object words put be entered into 
  229.  these varibles in the same way as there were entered as Object ID 
  230.  Words in the Creator, for example, the Object ID Words in 
  231.  Grannies Garden were entered like this.
  232.  
  233.   Object ID Word="Cake", Object ID Word="Key"
  234.  
  235.  So the TAKE$ and DROP$ varibles must have the same wording.
  236.  
  237.   TAKE$="Cake", DROP$="Key"
  238.  
  239.  Otherwise your game would ignore the lines.
  240.  
  241.    Lines 2420 to 2710  (Special Examine Object Events) 
  242.  
  243.  As with Take and Drop, we can cause something to happen if an 
  244.  object is examined by using a varible called EXAMINE$, in the 
  245.  TAKE$ example we saw how a key could be found behind a vase, one 
  246.  object found in another, so lets use an Examine Object event to 
  247.  enable the player to FIND the key inside the vase.
  248.  
  249.  2420 if EXAMINE$="Vase" and OBLOC(5)=NC then OBLOC(5)=LOCATION : 
  250.       print MESSAGE$(8) : SC=SC+30 : DONE=1
  251.  
  252.  So, if the vase is examined and the key has not yet been created 
  253.  then create it and put it at the players location.
  254.  
  255.    Lines 2870 to 3160  (Special Examine Location Events) 
  256.  
  257.  As you know, we can examine part of our location by clicking on 
  258.  it and the right examine message appears, but what if we wanted 
  259.  something to happen like examining a table could result in a 
  260.  plate being found, or an passage could be found by examining a 
  261.  wall. This is where these events come in.
  262.  
  263.  The Location Message option in the creator sets up these Examine 
  264.  Zones and allows you to enter the examine message for the zone, 
  265.  and as mentioned in Chapter 2, we can insert a false Examine Zone 
  266.  just by pressing 'RETURN' without typing anything in.
  267.  
  268.  We can take control of these zones in this section by defining 
  269.  the examine messages for the false zones as Game Messages, this 
  270.  line would create an hidden passage.
  271.  
  272.   2870 if Z=2 and and MAP(4,2)=0 then MAP(4,2)=5 : print 
  273.        MESSAGE$(9) : DONE=1
  274.   
  275.  As you know, each picture can have up to five zones for each Zone 
  276.  command choosen, the varible "Z" holds the number of the Examine 
  277.  Zone selected and the mouse button is checked to see if it has been 
  278.  clicked in Zone 2. The MAP array holds all the exits for each 
  279.  location, the format of this is this.
  280.  
  281.   MAP(Location,Zone)
  282.  
  283.   Location= (The players present location)
  284.   Zone= (The chosen Exit Zone) 
  285.    
  286.  The Map array tells the game which location the player is in and 
  287.  which Exit Zone he has selected, it equals another location 
  288.  number so we can use it to connect a location to another location
  289.  so in the above example we are connecting location 4 to location 
  290.  5 when the player clicks on Exit Zone 2. Other examples are..
  291.  
  292.   MAP(5,1)=10 : (Connects location 5 to 10 from Exit Zone 1)
  293.   MAP(1,5)=2 : (Connects location 1 to 2 from Exit Zone 5)
  294.   MAP(5,5)=8 : (Connects location 5 to 8 from Exit Zone 8)
  295.  
  296.  When we enter our Exit Zones in the Connections Menu, we can add 
  297.  False Exits Zones simply by entering nought when asked which 
  298.  location the previously selected zone leads to. so first our line
  299.  checks if the Exit Zone is still a false exit before carrying out
  300.  the rest of the line, if the zone is false  then MAP is set
  301.  to nought to indicate it's un-connected.
  302.  
  303.  So the above line checks if Exit Zone 2 at location 4 is still 
  304.  un-connected, and if so, connects it to location 5, and prints a 
  305.  game message to tell the player that he has found an hidden 
  306.  passage behind the wall.
  307.  
  308.    Lines 3380 to 3440   (Load varibles) 
  309.  
  310.  When you've been playing an adventure game for so long, its quite 
  311.  annoying to get so far then get killed, or have to finish the 
  312.  game to do something else. So what we Adventure Writers do is 
  313.  allow the player to save his or her postion in the game on disk 
  314.  and load it up when they play again to continue where they left 
  315.  off. This is done by the Stos file access commands.
  316.  
  317.  We shall look at saving in a moment, this section is used for 
  318.  loading the saved postion using the input# command.
  319.  
  320.  Unlike the "input" command which allows you to put a varible into 
  321.  memory, the "input#" allows you to take a varible from disk, so we 
  322.  can load it back into memory. So if we had a varible called 
  323.  TROLL, it would need to be saved as it was set to 1 and first but 
  324.  at the time of saving could have changed, so once it was saved we 
  325.  could load it back with "input#", like this.
  326.  
  327.  3380 input#1,TROLL
  328.  
  329.  The "#1" is the channel number, see Stos Manual for details.
  330.  
  331.    Lines 3470 to 3550  (Load number arrays) 
  332.  
  333.  This section is used to load number arrays, for example.
  334.  
  335.   3470 for X=1 to 50 : input#1,OBJECT(x) : next X
  336.   3480 for X=1 to 80 : for Y=1 to 5 : input#1,MAP(X,Y) : next Y : 
  337.       next X
  338.  
  339.    Lines 3570 to 3630  (Load word arrays) 
  340.  
  341.  As above, but for loading word arrays, for example.
  342.  
  343.   3570 for X=1 to 100 : input#1,SHAPE$(X) : next X
  344.  
  345.    Lines 3730 to 3790  (Save varibles) 
  346.  
  347.  Before we can load the varibles, we need to save them using the 
  348.  "print#" command like this.
  349.  
  350.  3730 print#1,TROLL
  351.  
  352.    Lines 3820 to 3900  (Save number arrays) 
  353.  
  354.  As Load, this section is used to save number arrays.
  355.  
  356.  3820 for X=1 to 50 : print#1 OBJECT(X) : next X
  357.  
  358.    Lines 3920 to 3990  (Save word arrays) 
  359.  
  360.  Guess what???, this is for saving word arrays.
  361.  
  362.  3920 for X=1 to 100 : print#1,SHAPE$(X) : next X
  363.  
  364.  Well thats the end of this Chapter, in Chapter 4 we shall have a 
  365.  look at the other zones and what can be done with them.
  366.  
  367.